//
//  IMWindowController.m
//  SIM
//
//  Created by 奕 朱 on 11-2-23.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "IMWindowController.h"
#import "ImageUtil.h"


@implementation IMWindowController

- (IBAction) buttonPressed {

	NSLog(@"button is pressed");
	
	NSOpenPanel *openPanel = [[NSOpenPanel openPanel] retain];
	
    [openPanel setMessage:@"Choose A File"];
	[openPanel setResolvesAliases:YES];
    [openPanel setAllowsMultipleSelection:NO];
	
	[openPanel beginSheetForDirectory:nil 
									  file:nil 
									 types:nil
							modalForWindow:currentWindow 
							 modalDelegate:self 
							didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) 
							   contextInfo:nil];
	
}

- (void)openPanelDidEnd:(NSOpenPanel *)panel 
		returnCode:(int)returnCode  
		contextInfo:(void  *)contextInfo {
	
	[ImageUtil resizeFromPath:[panel filename] 
					   toPath:@"/tmp/test.jpg" 
						width:30 height:30];
	
	NSLog(@"%@close window", [panel filename]);
	
}

@end
